<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>消息添加页面</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">
<style>
.layui-btn:not(.layui-btn-lg ):not(.layui-btn-sm):not(.layui-btn-xs) {
	height: 34px;
	line-height: 34px;
	padding: 0 8px;
}
</style>
</head>
<body>
	<form class="layui-form" action="">
		<div class="layui-form-item" style="margin-top: 20px;"
			onsubmit="false">
			<div class="layui-row">
    <div class="layui-col-xs6">
     <div class="layui-form-item" hidden="hidden">
				<label class="layui-form-label"><span style="color: red;">*
				</span>接收人id:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="mesreceiver" id="mesreceiver"
						lay-verify="required" lay-reqtext="接收人id不能为空" placeholder="请输入接收人id"
						value="" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><span style="color: red;">*
				</span>发送人:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="username" id="username"
						lay-verify="required" lay-reqtext="接收人不能为空" placeholder="请输入接收人"
						value="" class="layui-input" disabled="disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><span style="color: red;">*
				</span>接收人:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="suoshuzixunshi" id="suoshuzixunshi"
						lay-verify="required" lay-reqtext="接收人不能为空" placeholder="请输入接收人"
						value="" class="layui-input" disabled="disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><span style="color: red;">*
				</span>学生姓名:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="stuname" id="stuname"
						placeholder="请输入学生姓名" lay-verify="required" class="layui-input" disabled="disabled">
				</div>
			</div>
			<div class="layui-form-item" hidden="hidden">
				<label class="layui-form-label"><span style="color: red;">*
				</span>学生姓名id:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<input type="text" name="messtuid" id="messtuid"
						placeholder="请输入学生姓名" lay-verify="required" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">
				消息备注:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<textarea type="text" name="mesremarks" id="mesremarks"
						placeholder="请输入消息备注" lay-verify="required" class="layui-textarea"></textarea>
				</div>
			</div>
    </div>
    <div class="layui-col-xs6">
     <div class="layui-form-item  layui-form-text">
				<label class="layui-form-label">
				消息内容:</label>
				<div class="layui-input-inline" style="width: 350px;">
					<textarea name="mescontent" id="mescontent" placeholder="请输入消息内容"
						lay-verify="content0" class="layui-textarea"></textarea>
				</div>
			</div>
			
    </div>
  </div>
			
			
			<div class="layui-btn-container" style="text-align: center;">
				<button class="layui-btn" lay-filter="messBtu" lay-submit="">
					发送</button>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script src="js/Global.js" type="text/javascript" charset="utf-8"></script>
	<script>
		//加载了layui的form模块
			layui.use(['form','layedit'], function() {
				var form = layui.form,
					layer = layui.layer,
					$ = layui.$;
				var $ = layui.jquery; //引入jquery  同 var $ = layui.$;
				var layedit = layui.layedit;
				var mescontent=layedit.build('mescontent', {//建立富文本
				  height: 180 //设置编辑器高度
				});
				form.verify({
		            content0: function(value) {
		                return layedit.sync(mescontent);//获取富文本编辑器里面的值
		            }
		        });
				 $("#username").val(globalData.getUserName());
			//监听提交
			form.on('submit(messBtu)', function(data) {
				data.field.messender = globalData.getUid();
				if(data.field.messender != null) {
					$.post(globalData.server + "public/add", data.field, function(data) {
						if(data.count > 0) {
							var iframeIndex = parent.layer.getFrameIndex(window.name);
							parent.layer.close(iframeIndex);
						}
					}, "json");
				} else {
					layer.msg("发送失败");
				}

				return false;
			});

		});
	</script>
</body>
</html>